var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/umiConfig.ts
var umiConfig_exports = {};
__export(umiConfig_exports, {
  initUmiConfig: () => initUmiConfig
});
module.exports = __toCommonJS(umiConfig_exports);
function mergeConfig(defaultCfg, cfg) {
  Object.keys(cfg).forEach((key) => {
    if (Object.prototype.toString.call(cfg[key]) === "[object Object]") {
      defaultCfg[key] = { ...defaultCfg[key], ...cfg[key] };
    } else {
      defaultCfg[key] = cfg[key];
    }
  });
  return defaultCfg;
}
function initUmiConfig(config = {}) {
  const { chainWebpack, headScripts = [], mfsu, ...others } = config;
  const publicPath = process.env.NODE_ENV === "production" ? "./" : "/";
  const { shared, ...mfsuCfg } = mfsu || {};
  const productionConfig = mergeConfig(
    {
      runtimePublicPath: {},
      publicPath,
      headScripts: [`window.publicPath=window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__||'${publicPath}';`, ...headScripts],
      base: "/",
      ignoreMomentLocale: true,
      history: {
        type: "hash"
      },
      model: {},
      antd: { import: false },
      request: false,
      initialState: {},
      locale: {
        antd: true,
        default: "zh-CN"
      },
      mock: {},
      layout: false,
      dva: { skipModelValidate: true, lazyLoad: true },
      mfsu: {
        shared: {
          react: { singleton: true },
          "react-dom": { singleton: true },
          dva: { singleton: true },
          "@newgrand/iup-core": { singleton: true },
          "@newgrand/iup-ui": { singleton: true },
          ...shared
        },
        strategy: "eager",
        ...mfsuCfg
      }
    },
    others
  );
  if (process.env.NODE_ENV === "production") {
    productionConfig.hash = true;
    productionConfig.chainWebpack = function(config2, options) {
      const CompressionWebpackPlugin = require("compression-webpack-plugin");
      config2.plugin("compression-webpack-plugin").use(
        new CompressionWebpackPlugin({
          algorithm: "gzip",
          // 指定生成gzip格式
          test: /\.(js|css|json|txt|html|ico|svg)(\?.*)?$/i,
          // 匹配哪些格式文件需要压缩
          threshold: 10240,
          //对超过10k的数据进行压缩
          minRatio: 0.6
          // 压缩比例，值为0 ~ 1
        })
      );
      chainWebpack && chainWebpack(config2, options);
    };
  } else {
    if (!productionConfig.chainWebpack && chainWebpack) {
      productionConfig.chainWebpack = chainWebpack;
    }
  }
  return productionConfig;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  initUmiConfig
});
